﻿using System;

namespace Login.ADL
{
    public class tb_banji
    {
        /// <summary>
        /// 删除所有排课信息
        /// </summary>
        #region
        public static void delete()
        {
            string sql = "delete from tb_NoClass";
            //删除所有排课信息
            Helpsql.getxiu(sql);
            sql = "delete from tb_Class_Exp_Details";
            //删除所有班级实验信息
            Helpsql.getxiu(sql);
            sql = "delete from tb_Class";
            //删除所有班级
            Helpsql.getxiu(sql);
        }
        #endregion

        /// <summary>
        /// 班级名导入数据库
        /// </summary>
        /// <param name="banjiming"></param>
        #region
        public static void ClassName(string banjiming)
        {
            //构造向班级表中添加班级的sql语句
            string sql = "insert into tb_Class(ClassName)values('{0}')";
            sql = string.Format(sql, banjiming);
            //向班级表中添加班级
            Helpsql.getxiu(sql);
            //将该班级ID赋值给字符串
            string id = tb_shangkeClass.getClassId(banjiming);
            for (int classZu = 1; classZu < 3; classZu++)
            {
                //构造向排课结果表中添加班级的sql语句
                sql = "insert into tb_NoClass(ClassId,GroupId,Week2,Week3,Week4,Week5,Week6,Week7,Week8,Week9,Week10,Week11,Week12,Week13,Week14,Week15,Week16,Week17,TimeId)values('{0}','{1}','','','','','','','','','','','','','','','','','')";
                sql = string.Format(sql, id, classZu);
                //向排课结果表中添加班级
                Helpsql.getxiu(sql);
            }
        }
        #endregion

        /// <summary>
        /// 实验信息导入
        /// </summary>
        /// <param name="experimentId">实验ID</param>
        /// <param name="jianCheng">实验简称</param>
        /// <param name="mingCheng">实验名称</param>
        /// <param name="diDian">实验地点</param>
        /// <param name="teachar">教师名</param>
        #region
        public static void shiYanMing(int experimentId, string jianCheng,string mingCheng,string diDian,string teachar)
        {
            //构造添加实验信息的sql语句
            string sql = "update tb_Experiment set ExperimentNo='{0}',ExperimentName='{1}',Venue='{2}',Teacher='{3}' where ExperimentId='{4}'";
            sql = string.Format(sql, jianCheng, mingCheng, diDian, teachar, experimentId);
            //向实验信息表中添加信息
            Helpsql.getxiu(sql);
        }
        #endregion

        /// <summary>
        /// 删除实验信息
        /// </summary>
        #region
        public static void deleteShiYan()
        {
            //构造删除班级实验信息的sql语句
            string sql = "update tb_Experiment set ExperimentNo='',ExperimentName='',Venue='',Teacher=''";
            //删除班级实验信息
            Helpsql.getxiu(sql);
        }
        #endregion

    }
}
